#include "metadata.h"
#include "tag.h"
#include "fileref.h"
#include "tstring.h"

//http://developer.kde.org/~wheeler/taglib/api/tstring_8h.html
#define TS2QS(s) QString::fromUtf8(s.toCString(true))

MetaData MetaDataHelper::getMetaData(QString filename)
{
    TagLib::FileRef file(filename.toUtf8().data());
	TagLib::Tag *tag = file.tag();
    MetaData metadata;

    metadata.title = TS2QS(tag->title());
    metadata.artist = TS2QS(tag->artist());
    metadata.album = TS2QS(tag->album());

    return metadata;
}
